<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>培训经历操作页面</title>
    <script src="../../../../../res/js/jquery-3.4.1.min.js"></script>
    <script src="../../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../../res/js/Tools.js"></script>
    <link rel="stylesheet" href="../../../../../res/layui/css/layui.css" media="all">
    <link href="../../../../../res/echarts/eleTree.css" rel="stylesheet"/>
    <script src="../../../../../res/echarts/eleTree.js"></script>
    <link rel="shortcut icon" type="image/x-icon" href="../../../../../res/images/favicon.ico">
    <script src="../../../../../res/js/login_common.js" charset="utf-8"></script>
    <style type="text/css">
        body {
            padding: 10px;
        }
    </style>
    <script>
        $.ajaxSetup({
            async: false
        });
    </script>
</head>
<body>
<form class="layui-form layui-form-pane" id="formDId" action="" method="post" enctype="multipart/form-data">
    <input type="hidden" id="entryId" name="entryId">
    <div class="layui-form-item">
        <label class="layui-form-label">培训内容</label>
        <div class="layui-input-block">
            <input type="text" name="trainContent" id="trainContent" lay-verify="required" autocomplete="off" maxlength="50" placeholder="请输入培训内容" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">培训组织机构</label>
        <div class="layui-input-block">
            <input type="text" name="trainInstitutional" id="trainInstitutional" lay-verify="required" autocomplete="off" maxlength="50" placeholder="请输入培训组织机构" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">培训结果</label>
        <div class="layui-input-block">
            <input type="text" name="trainResult" id="trainResult"  autocomplete="off" maxlength="62" placeholder="请输入培训结果" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">培训时间</label>
            <div class="layui-input-block">
                <input type="text" name="strTime" class="layui-input" id="strTime" placeholder=" - ">
            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn site-demo-active" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-bg-red">重置按钮</button>
        </div>
    </div>
</form>
<script>
    var houses;
    var form=null;
    let alteration = getQueryString("alteration");
    layui.use(['form', 'layedit', 'laydate', 'layer'], function () {
        form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#strTime'
            ,range: true
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            // 单击之后提交按钮不可选,防止重复提交
            var DISABLED = 'layui-btn-disabled';
            // 增加样式
            $('.site-demo-active').addClass(DISABLED);
            // 增加属性
            $('.site-demo-active').attr('disabled', 'disabled');
            data.field.endTime = data.field.strTime.split(' - ')[1];
            data.field.startTime = data.field.strTime.split(' - ')[0];
            var url= getRootPath()+"oaEntryTrain/addOrUpdate";
            if(alteration){
                url = getRootPath() + "oaEntryTrain/addOrUpdates";
            }
            var data=postAjax(url,data.field);
            if (data.code === 1) {
                parent.layui.table.reload('oaEntryTrain');//刷新父页面
                //window.parent.location.reload();//刷新父页面
                const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            }  else {
                layer.msg("新增失败");
            }
            return false;
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

        //重新渲染表单函数
        function renderForm() {
            layui.use('form', function () {
                var form = layui.form(); //高版本建议把括号去掉，有的低版本，需要加()
                form.render();
            });
        }

        form.render();
        //修改操作
        var ide = getQueryString("id");
        if(ide) {
            $("#entryId").val(ide);
        }
    });
</script>
</body>
</html>